function updata()
{
  document.getElementById('light').style.display = 'block';
  document.getElementById('fade').style.display = 'block';
  var s = $('#table').bootstrapTable('getSelections');
  //alert(s.length);
  document.getElementById('name').value = s[0].name;
  document.getElementById('sex').value = s[0].sex;
  document.getElementById('address').value = s[0].address;
  document.getElementById('age').value = s[0].age;
  document.getElementById('disease').value = s[0].disease;
  $('#put').click(function ()
  {
    var s = $('#table').bootstrapTable('getSelections');
    var id = s[0].id;
    alert("id"+id);
    var name = document.getElementById('name').value;
    var age = document.getElementById('age').value;
    var address = document.getElementById('address').value;
    var disease = document.getElementById('disease').value;
    var sex = document.getElementById('sex').value;
    $.ajax({
      type: 'POST',
      url: 'DispatchAction?method=updataPatient',
      data: 'id=' + id + '&name=' + name + '&age=' + age + '&address=' + address + '&disease=' + disease + '&sex=' + sex,
      success: function (msg) {
        if (msg == 'true')
        {
          alert('修改成功');
          document.getElementById('light').style.display = 'none';
          document.getElementById('fade').style.display = 'none';
          $('#table').bootstrapTable('refresh');
          return true;
        } 
        else {
          alert('修改failuer');
          return false;
        }
      },
    });
  });
}
function insert()
{
  var name = document.getElementById('name2').value;
  var age = document.getElementById('age2').value;
  var address = document.getElementById('address2').value;
  var disease = document.getElementById('disease2').value;
  var sex = document.getElementById('sex2').value;
  $.ajax({
    type: 'POST',
    url: 'DispatchAction?method=insertPatient',
    data: 'name=' + name + '&age=' + age + '&address=' + address + '&disease=' + disease + '&sex=' + sex,
    success: function (msg) {
      if (msg == 'true')
      {
        alert('添加成功');
        document.getElementById('light2').style.display = 'none';
        document.getElementById('fade').style.display = 'none';
        $('#table').bootstrapTable('refresh');
        return true;
      } 
      else {
        alert('添加failuer');
        return false;
      }
    },
  });
}
function delect()
{
  var s = $('#table').bootstrapTable('getSelections');
  var last = JSON.stringify(s);
  $.ajax({
    type: 'POST',
    url: 'DispatchAction?method=delectPatient',
    data: 'json=' + last,
    success: function (msg) {
      if (msg) {
        alert('删除成功');
        $('#table').bootstrapTable('refresh');
      } 
      else {
        alert('删除失败!');
      }
    },
    // datatype:JSON
  });
}
